﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using RkLib.Configuration;
using RkLib;
using RkLib.Security;
namespace Ebenalp
{
    class gVar
    {
        public const string SFTWARE_NAME = "Ebenalp";
        public const string CFG = "CFG";
        public const string CFG_CONTROL = "CONTROL";
        public const string CFG_PIC = "PIC";
        public static string SftDataBaseDir = null;
        public static string SftCfgFile = null;


        public static void InitGVar()
        {
            SftDataBaseDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\";
            SftDataBaseDir += SFTWARE_NAME + "\\";
            PublicFunction.CreateFolder(SftDataBaseDir);
            SftCfgFile = SftDataBaseDir + "cfg.bin";
            Cfg.Initialize(ConfigFileType.INI, SftCfgFile);
        }
        public static void Terminate()
        {
            Cfg.Terminate();
        }
        public static string GetDescription()
        {
            string srcFile = "description.bin";
            if (File.Exists(srcFile))
            {
                string tmpFile = Path.GetTempFileName();
                AES.DecryptFile(srcFile, tmpFile);
                string str = File.ReadAllText(tmpFile);
                PublicFunction.DeleteFile(tmpFile);
                return str;
            }
            else
            {
                return "说明文件丢失";
            }

        }
        public static void FileOp()
        {
            string src = "description1.bin";
            string dst = "description.bin";
            AES.EncryptFile(src, dst);

            AES.DecryptFile(dst, "123.bin");
        }
    }
}
